//
//  CampusDetailLinkCell.m
//  ShowYork
//
//  Created by hxh on 2021/3/26.
//  Copyright © 2021 hxh. All rights reserved.
//

#import "CampusDetailLinkCell.h"

@interface CampusDetailLinkCell ()
@property (nonatomic,strong)UIButton *webBtn;
@property (nonatomic,strong)UIView *line;
@property (nonatomic,strong)UIButton *officeBtn;

@property (nonatomic,strong)UIImageView *webIcon;
@property (nonatomic,strong)UILabel *webLb;

@property (nonatomic,strong)UIImageView *officeIcon;
@property (nonatomic,strong)UILabel *officeLb;

@end

@implementation CampusDetailLinkCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}
- (void)setUI{

    self.webLb = [[UILabel alloc]init];
    self.webLb.text = @"网站";
    self.webLb.textColor = C102;
    self.webLb.font = font(12);
    [self.contentView addSubview:self.webLb];
    
    self.webIcon = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"campus_web_tag"]];
    [self.contentView addSubview:self.webIcon];
    
    self.officeLb = [[UILabel alloc]init];
    self.officeLb.text = @"招生办";
    self.officeLb.textColor = C102;
    self.officeLb.font = font(12);
    [self.contentView addSubview:self.officeLb];
    
    self.officeIcon = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"campus_office_tag"]];
    [self.contentView addSubview:self.officeIcon];
    
    self.webBtn = [[UIButton alloc]init];
    [self.webBtn addTarget:self action:@selector(webMethod) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.webBtn];
    
    self.officeBtn = [[UIButton alloc]init];
    [self.officeBtn addTarget:self action:@selector(officeMethod) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.officeBtn];
    
    
    self.line = [[UIView alloc]init];
    self.line.backgroundColor = RGBA(216, 216, 216, 1);
    [self.contentView addSubview:self.line];
    
    [self.webBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.bottom.equalTo(self.contentView);
        make.width.mas_equalTo(kScreenW/2);
        make.height.mas_equalTo(56).priorityHigh();
    }];
    [self.officeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.equalTo(self.contentView);
        make.width.mas_equalTo(kScreenW/2);
        make.height.mas_equalTo(56);
    }];
    [self.webLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.webBtn);
        make.centerX.equalTo(self.webBtn).offset(20);
    }];
    [self.webIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.webBtn);
        make.right.equalTo(self.webLb.mas_left).offset(-8);
    }];
    
    [self.officeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.officeBtn);
        make.centerX.equalTo(self.officeBtn).offset(20);
    }];
    [self.officeIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.officeBtn);
        make.right.equalTo(self.officeLb.mas_left).offset(-8);
    }];

    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(1, 14));
    }];
}

- (void)webMethod{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectedLinkByTag:)]) {
        [self.delegate didSelectedLinkByTag:0];
    }
}

- (void)officeMethod{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectedLinkByTag:)]) {
        [self.delegate didSelectedLinkByTag:1];
    }
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    NSString *ID = @"CampusDetailLinkCell";
    CampusDetailLinkCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[CampusDetailLinkCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}



@end
